Story - 1

In this story we are looking at effect of watching video games. In this particular dataset we have three variable -

  1. No. of hours / week used to watch (violent) videos
  2. Aggression
  3. Callous Unemotional Trait

Therefore, this story is about examining relationship between aggression and time spent in watching videos.

setwd("E:/Outline/WD/D3.1")
dir()
##  [1] "aggression.csv"                      
##  [2] "Categorical analysis.csv"            
##  [3] "Categorical analysis.xlsx"           
##  [4] "correlation analysis.pdf"            
##  [5] "Data visualisation - An Overview.Rmd"
##  [6] "desire.xlsx"                         
##  [7] "e_stress.csv"                        
##  [8] "Examing Relations.R"                 
##  [9] "frienship.csv"                       
## [10] "mediation"                           
## [11] "moderation"                          
## [12] "Moderation---Mediation.Rmd"          
## [13] "Moderation & Mediation.Rmd"          
## [14] "path analysis.R"                     
## [15] "pmi.csv"                             
## [16] "relation.csv"
video <- read.csv("aggression.csv")
str(video)
## 'data.frame':    442 obs. of  5 variables:
##  $ X       : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ ID      : int  69 55 7 96 130 124 72 139 102 179 ...
##  $ Aggress : int  13 38 30 23 25 46 41 22 35 23 ...
##  $ Vid_Game: int  16 12 32 10 11 29 23 15 20 20 ...
##  $ CaUnTs  : int  0 0 0 1 1 1 2 3 3 3 ...
summary(video)
##        X               ID           Aggress         Vid_Game         CaUnTs    
##  Min.   :  1.0   Min.   :  1.0   Min.   : 9.00   Min.   : 1.00   Min.   : 0.0  
##  1st Qu.:111.2   1st Qu.:111.2   1st Qu.:32.00   1st Qu.:17.00   1st Qu.:11.0  
##  Median :221.5   Median :221.5   Median :40.00   Median :22.00   Median :18.0  
##  Mean   :221.5   Mean   :221.5   Mean   :40.05   Mean   :21.84   Mean   :18.6  
##  3rd Qu.:331.8   3rd Qu.:331.8   3rd Qu.:48.00   3rd Qu.:26.00   3rd Qu.:26.0  
##  Max.   :442.0   Max.   :442.0   Max.   :82.00   Max.   :38.00   Max.   :43.0

The variable which are of our interst are Agress, Vi_Game and CaUnTs. So this is a small story which just involves three variables.

plot_ly(data = video,x = ~Vid_Game, y = ~Aggress, color = ~CaUnTs, size = ~CaUnTs, type = "scatter")
## No scatter mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
## Warning: `line.width` does not currently support multiple values.

Now , we all know the agression is a behaviour , which depends upon attitude. Now CaUnTs which inplies Casual and Unemotional aspect of the subjects - may be considered as attitude.

I am considering them as the context. In any visalisaion , interplay of variable should be seen in a context.

From the above plot one can note that -

And to be sure the next plot is drawn.

ggplot(data = video, aes(x = Vid_Game, y = Aggress)) + geom_point(aes(size = CaUnTs, color = CaUnTs)) + facet_grid(cut(video$CaUnTs,4)) + geom_smooth(method = "lm", color = "red")

In this plot (static in nature) we have explored the relation ship between exposure to violent videos and aggression.

Four sub-plots shows , that people having higher CaUnTs (as represented by larges points) shows more aggression as they are exposed to videos.

So the relationship between Agression and No.of hours spent to watch videos(violent) depends upon the value of CaUnTs. This phenomena in statistics is known as “MODERATION”. And we have used to unravel this relationship with the help of visualisaiton.

In the following section we shall see how such relationships should modelled. Let us take only two variables , i.e. no of hours spent to watch violent videoa and second is CaUnTs.

library(psych)
## Warning: package 'psych' was built under R version 3.5.3
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
m1 <- lm(Aggress ~ Vid_Game + CaUnTs, data = video)
summary(m1)
## 
## Call:
## lm(formula = Aggress ~ Vid_Game + CaUnTs, data = video)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -27.952  -6.696  -0.168   7.022  32.499 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 21.76433    1.80731  12.042  < 2e-16 ***
## Vid_Game     0.18769    0.06940   2.705  0.00711 ** 
## CaUnTs       0.76312    0.05024  15.191  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.13 on 439 degrees of freedom
## Multiple R-squared:  0.3559, Adjusted R-squared:  0.353 
## F-statistic: 121.3 on 2 and 439 DF,  p-value: < 2.2e-16

So, R^2 stands at 35.6%. At the same time all the coefficients are significant.

Since , the relationship between agression and no of hours spent to watch video is moderated by the attitude (CaUnTs) - we are considering to inlcude “an interaction term” - which is the product of the two predictors.

video$Interaction = video$Vid_Game * video$CaUnTs

summary(lm(Aggress ~ Vid_Game + CaUnTs + Interaction, data = video))
## 
## Call:
## lm(formula = Aggress ~ Vid_Game + CaUnTs + Interaction, data = video)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -29.7144  -6.9087  -0.1923   6.9036  29.2290 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 33.120233   3.427254   9.664  < 2e-16 ***
## Vid_Game    -0.333597   0.150826  -2.212 0.027495 *  
## CaUnTs       0.168949   0.161049   1.049 0.294731    
## Interaction  0.027062   0.006981   3.877 0.000122 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.976 on 438 degrees of freedom
## Multiple R-squared:  0.3773, Adjusted R-squared:  0.373 
## F-statistic: 88.46 on 3 and 438 DF,  p-value: < 2.2e-16

From the summary, we can not that R^2 has increased to 37.7%. Also we can observe the following -

  1. CaUnTs is NO LONGER a significant predictor

  2. Interaction term is signifcant at .1% level.

  3. Vid_Game i.e. hours spent to watch video is signficant at 5%.

Story - 3

The third story is about the study done on moderating role of social ties on entrepreneurs’ depressed affect and withdrawal intentions in response to economic stress by Pollack, J., VanEpps, E. M., & Hayes, A. F. (2012). (The . Journal of Organizational Behavior, 33, 789-810.)

stress <- read.csv("e_stress.csv")

str(stress)
## 'data.frame':    262 obs. of  7 variables:
##  $ tenure  : num  1.67 0.58 0.58 2 5 9 0 2.5 0.5 0.58 ...
##  $ estress : num  6 5 5.5 3 4.5 6 5.5 3 5.5 6 ...
##  $ affect  : num  2.6 1 2.4 1.16 1 1.5 1 1.16 1.33 3 ...
##  $ withdraw: num  3 1 3.66 4.66 4.33 3 1 1 2 4 ...
##  $ sex     : int  1 0 1 1 1 1 0 0 1 1 ...
##  $ age     : int  51 45 42 50 48 48 51 47 40 43 ...
##  $ ese     : num  5.33 6.05 5.26 4.35 4.86 5.05 3.66 6.13 5.26 4 ...
summary(stress)
##      tenure          estress         affect         withdraw    
##  Min.   : 0.000   Min.   :1.00   Min.   :1.000   Min.   :1.000  
##  1st Qu.: 0.940   1st Qu.:3.50   1st Qu.:1.160   1st Qu.:1.000  
##  Median : 4.000   Median :4.50   Median :1.330   Median :2.000  
##  Mean   : 5.929   Mean   :4.62   Mean   :1.598   Mean   :2.321  
##  3rd Qu.: 8.980   3rd Qu.:5.50   3rd Qu.:1.830   3rd Qu.:3.000  
##  Max.   :33.000   Max.   :7.00   Max.   :5.000   Max.   :7.000  
##       sex              age             ese       
##  Min.   :0.0000   Min.   :23.00   Min.   :2.530  
##  1st Qu.:0.0000   1st Qu.:36.00   1st Qu.:5.000  
##  Median :1.0000   Median :44.00   Median :5.730  
##  Mean   :0.6183   Mean   :43.79   Mean   :5.607  
##  3rd Qu.:1.0000   3rd Qu.:51.00   3rd Qu.:6.330  
##  Max.   :1.0000   Max.   :71.00   Max.   :7.000

Let us first understand the experiment - characters / variables -

So, the strings of relationships starts with economic stress and ends with withdrawl symptoms.

Let us the exploration beigns -

plot_ly(data = stress) %>% add_pie(values = table(stress$sex), labels = c("female", "male") ) 
plot_ly(data = stress) %>% add_pie(values = table(cut(stress$age,5)), labels = c("< 32.6", "> 32.6 & <=42.2", ">42.2 & <=51.8", ">51.8 & <=61.4", ">61.4 & <=71"))
plot_ly(data = stress) %>% add_pie(values = table(cut(stress$tenure,5)), labels = c("<=6.6 yrs", ">6.6 & <=13.2 yrs", ">13.2 & <=19.2 yrs", ">19.8 & <= 26.4 yrs" , "> 26.4 & <= 33"))

Demographic profile -

  1. Gender profile - 62% male and 38% female

  2. Age profile - 30% of respondetns belongs age range 42 to 52; appraox 28% belongs to 32 to 42. 17% belong to lesst 32 years

  3. Tenure profile - 68% respondents have less than 6.6 years of experience and 20% has expereince of greater than 6.6 and less than 13.2 years. So this two groups constitutes almost 88% of the population.

Now, we shall explore some relationship among the variables, following variables are closely related -

library(ppcor)
## Warning: package 'ppcor' was built under R version 3.5.3
p_cor <- pcor(stress)

cor_est <- p_cor$estimate
 
cor_est<- as.data.frame(cor_est)

plot_ly(data = cor_est, x = rownames(cor_est), y = colnames(cor_est), z = as.matrix(cor_est), colours = "RdBu") %>% add_heatmap()
## Warning: 'heatmap' objects don't have these attributes: 'colours'
## Valid attributes include:
## 'type', 'visible', 'opacity', 'name', 'uid', 'ids', 'customdata', 'meta', 'hoverinfo', 'hoverlabel', 'stream', 'transforms', 'uirevision', 'z', 'x', 'x0', 'dx', 'y', 'y0', 'dy', 'text', 'hovertext', 'transpose', 'xtype', 'ytype', 'zsmooth', 'connectgaps', 'xgap', 'ygap', 'zhoverformat', 'hovertemplate', 'zauto', 'zmin', 'zmax', 'zmid', 'colorscale', 'autocolorscale', 'reversescale', 'showscale', 'colorbar', 'coloraxis', 'xcalendar', 'ycalendar', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'metasrc', 'hoverinfosrc', 'zsrc', 'xsrc', 'ysrc', 'textsrc', 'hovertextsrc', 'hovertemplatesrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
  1. From the above correlation diagram that “withdrawal” phenomena is most strongly related with affect (depression),economic stress and ese (business related social ties).

  2. affect (depression) is strongly connected with economic stress.

  3. economic stress (estress) is strongly correlated with affect (depression)

ggplot(data = stress, aes(y = withdraw , x = estress), type =  "scatter") + geom_smooth(method = "lm")

ggplot(data = stress, aes(y = withdraw , x = estress), type =  "scatter") + geom_smooth(method = "lm") + facet_wrap(stress$sex)

ggplot(data = stress, aes(y = withdraw , x = estress), type =  "scatter") + geom_smooth(method = "lm") + facet_wrap(cut(stress$tenure,4))

  1. As expected with increase in economic stress we find that tendency to withdraw increases. Next , we will see whether this relationship is modified by any other variables.

  2. As can be seen that the gender modified the relationship.

  3. Tenure also modifes the relationship.

ggplot(data = stress, aes(y = withdraw , x = ese), type =  "scatter") + geom_smooth(method = "lm")

ggplot(data = stress, aes(y = withdraw , x = ese), type =  "scatter") + geom_smooth(method = "lm") + facet_wrap(stress$sex) # gender is not modifyig the relation

ggplot(data = stress, aes(y = withdraw , x = ese), type =  "scatter") + geom_smooth(method = "lm") + facet_wrap(cut(stress$tenure,4))

  1. as expected / hypothesised , with greater intensity of communication within business network leads to lesser tendency of withdrawal.

  2. Tenure does modfy the relationship , but gender has no significant role.

ggplot(data = stress, aes(y = withdraw , x = affect), type =  "scatter") + geom_smooth(method = "lm") 

ggplot(data = stress, aes(y = withdraw , x = affect), type =  "scatter") + geom_smooth(method = "lm") + facet_wrap(cut(stress$tenure,4))

  1. In line with the expectation increase in depression will lead higher temdency to withdraw.

  2. The direction of the relationship remains same, when gender is factored into.

library(ppcor)

pcor(stress)
## $estimate
##                tenure     estress      affect     withdraw         sex
## tenure    1.000000000  0.07723098 -0.08668162 -0.001028251 -0.03007565
## estress   0.077230978  1.00000000  0.33358282 -0.108779029  0.13051237
## affect   -0.086681616  0.33358282  1.00000000  0.387298163 -0.01014002
## withdraw -0.001028251 -0.10877903  0.38729816  1.000000000  0.05852061
## sex      -0.030075653  0.13051237 -0.01014002  0.058520611  1.00000000
## age       0.257049090  0.03219888 -0.01518905 -0.041546676  0.08727015
## ese      -0.049415031 -0.09514586 -0.12748255 -0.173581975  0.06583409
##                  age         ese
## tenure    0.25704909 -0.04941503
## estress   0.03219888 -0.09514586
## affect   -0.01518905 -0.12748255
## withdraw -0.04154668 -0.17358198
## sex       0.08727015  0.06583409
## age       1.00000000 -0.07836776
## ese      -0.07836776  1.00000000
## 
## $p.value
##                tenure      estress       affect     withdraw        sex
## tenure   0.0000000000 2.172345e-01 1.659158e-01 9.869123e-01 0.63129307
## estress  0.2172345473 0.000000e+00 4.267181e-08 8.176633e-02 0.03652582
## affect   0.1659158107 4.267181e-08 0.000000e+00 1.264791e-10 0.87148804
## withdraw 0.9869122785 8.176633e-02 1.264791e-10 0.000000e+00 0.35010557
## sex      0.6312930716 3.652582e-02 8.714880e-01 3.501056e-01 0.00000000
## age      0.0000303237 6.073888e-01 8.085276e-01 5.072771e-01 0.16304914
## ese      0.4302268311 1.281791e-01 4.114384e-02 5.264631e-03 0.29307627
##                   age         ese
## tenure   0.0000303237 0.430226831
## estress  0.6073888166 0.128179069
## affect   0.8085275899 0.041143839
## withdraw 0.5072770936 0.005264631
## sex      0.1630491364 0.293076271
## age      0.0000000000 0.210521405
## ese      0.2105214047 0.000000000
## 
## $statistic
##               tenure    estress     affect    withdraw        sex        age
## tenure    0.00000000  1.2369744 -1.3894241 -0.01641986 -0.4804870  4.2474667
## estress   1.23697437  0.0000000  5.6505493 -1.74743114  2.1020953  0.5144416
## affect   -1.38942410  5.6505493  0.0000000  6.70820043 -0.1619315 -0.2425777
## withdraw -0.01641986 -1.7474311  6.7082004  0.00000000  0.9361035 -0.6640206
## sex      -0.48048703  2.1020953 -0.1619315  0.93610351  0.0000000  1.3989299
## age       4.24746669  0.5144416 -0.2425777 -0.66402055  1.3989299  0.0000000
## ese      -0.79005995 -1.5262817 -2.0524797 -2.81460925  1.0535718 -1.2552933
##                ese
## tenure   -0.790060
## estress  -1.526282
## affect   -2.052480
## withdraw -2.814609
## sex       1.053572
## age      -1.255293
## ese       0.000000
## 
## $n
## [1] 262
## 
## $gp
## [1] 5
## 
## $method
## [1] "pearson"
# option -1 #

summary(lm(withdraw ~ estress + ese, data = stress))
## 
## Call:
## lm(formula = withdraw ~ estress + ese, data = stress)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.2173 -1.0154 -0.1840  0.9297  5.2005 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.97852    0.55314   7.193 6.82e-12 ***
## estress      0.02308    0.05345   0.432  0.66627    
## ese         -0.31459    0.08056  -3.905  0.00012 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.214 on 259 degrees of freedom
## Multiple R-squared:  0.05949,    Adjusted R-squared:  0.05222 
## F-statistic: 8.191 on 2 and 259 DF,  p-value: 0.0003554
# Option - 2 #

summary(lm(withdraw ~ estress + ese + estress * ese, data = stress))
## 
## Call:
## lm(formula = withdraw ~ estress + ese + estress * ese, data = stress)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.3804 -1.0368 -0.1641  0.9369  4.9653 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)  2.45506    1.81526   1.352    0.177
## estress      0.33165    0.35424   0.936    0.350
## ese         -0.05447    0.30600  -0.178    0.859
## estress:ese -0.05296    0.06010  -0.881    0.379
## 
## Residual standard error: 1.214 on 258 degrees of freedom
## Multiple R-squared:  0.06231,    Adjusted R-squared:  0.05141 
## F-statistic: 5.715 on 3 and 258 DF,  p-value: 0.0008419
# option - 3 #

summary(lm(withdraw ~ affect, data = stress))
## 
## Call:
## lm(formula = withdraw ~ affect, data = stress)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.1028 -0.8919 -0.2092  0.8713  2.8713 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.17416    0.17035   6.893 4.13e-11 ***
## affect       0.71772    0.09713   7.389 2.02e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.136 on 260 degrees of freedom
## Multiple R-squared:  0.1735, Adjusted R-squared:  0.1704 
## F-statistic:  54.6 on 1 and 260 DF,  p-value: 2.02e-12
summary(lm(affect ~ ese + estress + ese * estress, data = stress))
## 
## Call:
## lm(formula = affect ~ ese + estress + ese * estress, data = stress)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4413 -0.4153 -0.1620  0.2817  3.6485 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -1.7265     0.9755  -1.770 0.077952 .  
## ese           0.4373     0.1645   2.659 0.008316 ** 
## estress       0.8546     0.1904   4.489 1.08e-05 ***
## ese:estress  -0.1197     0.0323  -3.706 0.000257 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6526 on 258 degrees of freedom
## Multiple R-squared:  0.1961, Adjusted R-squared:  0.1868 
## F-statistic: 20.98 on 3 and 258 DF,  p-value: 3.391e-12
library(psych)

stress$inter1 <- stress$tenure * stress$estress

stress$inter2 <- stress$tenure * stress$ese

mediate("withdraw",c("estress", "ese"), m = "affect", data = stress,plot=T)

## 
## Mediation/Moderation Analysis 
## Call: mediate(y = "withdraw", x = c("estress", "ese"), m = "affect", 
##     data = stress, plot = T)
## 
## The DV (Y) was  withdraw . The IV (X) was  estress ese . The mediating variable(s) =  affect .
## 
## Total effect(c) of  estress  on  withdraw  =  0.02   S.E. =  0.05  t  =  0.43  df=  260   with p =  0.67
## Direct effect (c') of  estress  on  withdraw  removing  affect  =  -0.09   S.E. =  0.54  t  =  5.1  df=  258   with p =  6.4e-07
## Indirect effect (ab) of  estress  on  withdraw  through  affect   =  0.11 
## Mean bootstrapped indirect effect =  0.11  with standard error =  0.03  Lower CI =  0.06    Upper CI =  0.17
## 
## Total effect(c) of  ese  on  withdraw  =  -0.31   S.E. =  0.08  t  =  -3.91  df=  260   with p =  0.00012
## Direct effect (c') of  ese  on  withdraw  removing  affect  =  -0.21   S.E. =  0.05  t  =  -1.7  df=  258   with p =  0.09
## Indirect effect (ab) of  ese  on  withdraw  through  affect   =  -0.11 
## Mean bootstrapped indirect effect =  -0.1  with standard error =  0.04  Lower CI =  -0.19    Upper CI =  -0.03
## R = 0.45 R2 = 0.2   F = 21.96 on 3 and 258 DF   p-value:  1.29e-15 
## 
##  To see the longer output, specify short = FALSE in the print statement or ask for the summary

Now the above set of regtession can be structured in the following manner (error term ignored)

withdraw = a1 * ese + a2 * estress + a3 * affect - (equation # 1)

affect = b1 * ese + b2 * estress (equation # 2)

ese = c1 * estress (equation # 3)

Therefore, the above system of equation can be written as follows by substrituting the values of “ese” and “affect”

withdrraw = a1 * c1 * estress + a2 * estress + a3 * (b1 * ese + b2 * estress)

= (a1 * c1 + a2) * estress + a3 * (b1 * c1 * ese + b2* estress)

It can also be noted that as we substitute , we end up multiplying the regression coefficient. This can be considered as “Indirect effect”.

In context of first equation , “a1” is the total effect and (a1 * c1) is the indirect effect. The difference between total effect and indirect effect is “Direct Effect”.

summary(lm(ese ~ estress, data = stress)) # c1 = -0.10
## 
## Call:
## lm(formula = ese ~ estress, data = stress)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.9849 -0.6162  0.1238  0.6844  1.6426 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  6.09254    0.19641  31.019   <2e-16 ***
## estress     -0.10502    0.04063  -2.585   0.0103 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9345 on 260 degrees of freedom
## Multiple R-squared:  0.02505,    Adjusted R-squared:  0.0213 
## F-statistic:  6.68 on 1 and 260 DF,  p-value: 0.0103
summary(lm(affect ~ ese + estress, data = stress)) # b1 = -0.15 , b2 = 0.15
## 
## Call:
## lm(formula = affect ~ ese + estress, data = stress)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.0357 -0.3980 -0.1338  0.2047  4.1803 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.71716    0.30462   5.637 4.51e-08 ***
## ese         -0.15064    0.04436  -3.396 0.000792 ***
## estress      0.15706    0.02944   5.335 2.08e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6685 on 259 degrees of freedom
## Multiple R-squared:  0.1533, Adjusted R-squared:  0.1468 
## F-statistic: 23.45 on 2 and 259 DF,  p-value: 4.35e-10
summary(lm(affect ~ ese + estress, data = stress))
## 
## Call:
## lm(formula = affect ~ ese + estress, data = stress)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.0357 -0.3980 -0.1338  0.2047  4.1803 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.71716    0.30462   5.637 4.51e-08 ***
## ese         -0.15064    0.04436  -3.396 0.000792 ***
## estress      0.15706    0.02944   5.335 2.08e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6685 on 259 degrees of freedom
## Multiple R-squared:  0.1533, Adjusted R-squared:  0.1468 
## F-statistic: 23.45 on 2 and 259 DF,  p-value: 4.35e-10
mediate("withdraw",c("estress", "ese"), m = "affect", data = stress,plot=T)

## 
## Mediation/Moderation Analysis 
## Call: mediate(y = "withdraw", x = c("estress", "ese"), m = "affect", 
##     data = stress, plot = T)
## 
## The DV (Y) was  withdraw . The IV (X) was  estress ese . The mediating variable(s) =  affect .
## 
## Total effect(c) of  estress  on  withdraw  =  0.02   S.E. =  0.05  t  =  0.43  df=  260   with p =  0.67
## Direct effect (c') of  estress  on  withdraw  removing  affect  =  -0.09   S.E. =  0.54  t  =  5.1  df=  258   with p =  6.4e-07
## Indirect effect (ab) of  estress  on  withdraw  through  affect   =  0.11 
## Mean bootstrapped indirect effect =  0.11  with standard error =  0.03  Lower CI =  0.06    Upper CI =  0.17
## 
## Total effect(c) of  ese  on  withdraw  =  -0.31   S.E. =  0.08  t  =  -3.91  df=  260   with p =  0.00012
## Direct effect (c') of  ese  on  withdraw  removing  affect  =  -0.21   S.E. =  0.05  t  =  -1.7  df=  258   with p =  0.09
## Indirect effect (ab) of  ese  on  withdraw  through  affect   =  -0.11 
## Mean bootstrapped indirect effect =  -0.1  with standard error =  0.04  Lower CI =  -0.19    Upper CI =  -0.03
## R = 0.45 R2 = 0.2   F = 21.96 on 3 and 258 DF   p-value:  1.29e-15 
## 
##  To see the longer output, specify short = FALSE in the print statement or ask for the summary